import {
  createRouter,
  RouteLocationNormalized,
  createWebHashHistory
} from 'vue-router';
import routes from './routes';

const router = createRouter({
  routes,
  history: createWebHashHistory(),
  scrollBehavior() {
    return { top: 0 };
  }
});

// 路由守卫
router.beforeEach(
  (to: RouteLocationNormalized, from: RouteLocationNormalized, next) => {
    console.log('router.beforeEach', to, from);
    next();
  }
);

router.afterEach((to) => {
  console.log('router.afterEach', to);
});

export default router;
